package com.example.leetcode.bfs;

import com.example.leetcode.bfs.common.BFSUtils;
import com.example.leetcode.tree.common.TreeNode;
import com.example.leetcode.tree.common.TreeUtils;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 * int val;
 * TreeNode left;
 * TreeNode right;
 * TreeNode() {}
 * TreeNode(int val) { this.val = val; }
 * TreeNode(int val, TreeNode left, TreeNode right) {
 * this.val = val;
 * this.left = left;
 * this.right = right;
 * }
 * }
 */
class Solution112 {
    public boolean hasPathSum(TreeNode root, int targetSum) {
//        return DFSUtils.hasPathSum(root, targetSum);
        return BFSUtils.hasPathSum(root, targetSum);
    }
}

public class leetcode112 {
    public static void main(String[] args) {
        Solution112 solution112 = new Solution112();
        Integer[] nums = {5, 4, 8, 11, null, 13, 4, 7, 2, null, null, null, 1};
        Integer[] nums1 = {1, 2, 3};
        Integer[] nums2 = {};
        TreeNode root = TreeUtils.generateLeetcodeTree(nums);
        TreeNode root1 = TreeUtils.generateLeetcodeTree(nums1);
        TreeNode root2 = TreeUtils.generateLeetcodeTree(nums2);
        System.out.println(solution112.hasPathSum(root, 22));
        System.out.println(solution112.hasPathSum(root1, 5));
        System.out.println(solution112.hasPathSum(root1, 3));
        System.out.println(solution112.hasPathSum(root2, 0));
    }
}
